#include <bits/stdc++.h>
using namespace std;
int main() {
	int x;
	cin >> x;
	for (int i = 1; i <= 2025; i++) {
		if ((x & i) + (x | i) == 2025) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}
